﻿package mortal.game.view.guild.otherpanel
{
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.cache.guild.module.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.guild.cellrender.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildWareHouseMyApplyListPanel extends GuildOtherBasePanel
    {
        private var _list:GTileList;
        private var _pageSelecter:PageSelecter;
        private static var _instance:GuildWareHouseMyApplyListPanel;

        public function GuildWareHouseMyApplyListPanel(param1:ILayer = null)
        {
            setSize(295, 340);
            super(param1);
            if (_instance)
            {
                throw new Error("单例");
            }
            title = "" + Language.getString(71244);
            return;
        }// end function

        override public function layoutUI() : void
        {
            super.layoutUI();
            this._pageSelecter = UIFactory.pageSelecter(95, 305, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.ComboBg, new GTextFormat());
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.pageTextBoxSize = 36;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this._list = UIFactory.tileList(19, 35, 450, 230, this);
            this._list.rowHeight = 52;
            this._list.columnWidth = 274;
            this._list.rowCount = 5;
            this._list.columnCount = 1;
            this._list.setStyle("cellRenderer", GuildWareHouseMyApplyListCellRenderer);
            Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_getMyApplyList));
            return;
        }// end function

        private function updataList() : void
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.guild.selfGuildInfo.wareHouse;
            var _loc_3:* = this._list.rowCount * this._list.columnCount;
            var _loc_4:* = (this._pageSelecter.currentPage - 1) * _loc_3;
            var _loc_5:* = _loc_4 + _loc_3;
            var _loc_6:* = _loc_4;
            while (_loc_6 < _loc_5)
            {
                
                if (_loc_6 < _loc_2.myApplyList.length)
                {
                    _loc_1.addItem(_loc_2.myApplyList[_loc_6]);
                }
                _loc_6++;
            }
            this._list.dataProvider = _loc_1;
            this._list.drawNow();
            var _loc_7:* = Cache.instance.guild.selfGuildInfo.wareHouse.myApplyList.length;
            this._pageSelecter.maxPage = Math.ceil(_loc_7 / this._list.rowCount * this._list.columnCount);
            return;
        }// end function

        override public function update() : void
        {
            super.update();
            this.updataList();
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.updataList();
            return;
        }// end function

        override protected function setWindowCenter() : void
        {
            _windowCenter = ResourceConst.getScaleBitmap(ImagesConst.PanelBg);
            return;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

        public static function get instance() : GuildWareHouseMyApplyListPanel
        {
            if (_instance == null)
            {
                _instance = new GuildWareHouseMyApplyListPanel;
            }
            return _instance;
        }// end function

    }
}
